package cn.cqone.crm.controller;


import cn.cqone.crm.domain.Employee;
import cn.cqone.crm.query.EmployeeQuery;
import cn.cqone.crm.service.EmployeeService;
import cn.cqone.crm.utils.JSONResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@ResponseBody
@RequestMapping("/employee")
@CrossOrigin
@RequiresPermissions("employee:main")
public class EmployeeController extends BaseController<Employee,Long, EmployeeQuery>{
    @Autowired
    private EmployeeService employeeService;

    //取出当前角色的某些权限
    @RequestMapping(value = "/updateEmployeeRoleById/{employee_id}/{role_id}",method = RequestMethod.POST)
    public JSONResult updateEmployeeRoleById(@PathVariable("employee_id") Long employee_id, @PathVariable("role_id") Long role_id){
        try{
            employeeService.updateEmployeeRoleById(employee_id,role_id);
            return JSONResult.ok();
        }catch (Exception e){
            e.printStackTrace();
            return JSONResult.error("服务器异常,我们正在殴打程序员...");
        }
    }
}
